<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:include="public/page_css::page_css ('查看库位')" />

<body>
<input type="hidden" class="layui-input" th:value="${kwzlx}" id="kwzlx" name="kwzlx"/>
<form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
        <input type="hidden" class="layui-input" th:value="${id}" id="kwzid" name="kwzid"/>
</form>
<div class="group-button" id="toolbar">
    <input type="button"  value="新增" style="background-color: #40AFFE;width:58px" onclick="chakanAdd()"/>
</div>
<section class="panel panel-padding layui-card-body">
    <div class="pro">
        <table id="table" class="table text-nowrap"></table>
    </div>
</section>
</body>
<div th:include="public/public_js::public_js"></div>
<script>
layui.use(['list','layer','zzpUtils','jquery','laydate'],function () {
       var zzpUtils= layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;
            var form = layui.form;
            window.operateEvent ={
                "click #delRow": function (e, value, row, index) {//行按钮删除btn_stop
                    delRowDialog(row.id);
                },
            }
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination:true,
            url: '/wmslibrarypositiongroup/getWmsLibrarypositionIds',
            columns: [
             {
                field: 'mc',
                title: '库位名称'
            },{
                field: 'show_lx',
                title: '库位类型'
            },{
                field: 'cs',
                title: '库位层数'
            }, {
                field: 'caozuo',
                title: '操作',
                width:120,
                events: operateEvent,
                formatter: operateFormatter
            }],
            queryParams: function () {//查询条件
                return  zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            }
        });
        /*表格右侧按钮*/
        function operateFormatter(value, row, index) {
                return [
                    '<a class="layui-btn layui-btn-xs" id="delRow">删除</a>'
                ].join('')
        }
        //跳新增库位页面
        window.chakanAdd =  function () {
            layer.open({
                type: 2,
                area: ['80%', '80%'],
                content: "/zxsdwms/groupRouter/toChakanKwAdd?kwzid=" + $('#kwzid').val()+"&kwzlx="+$('#kwzlx').val(),
                end: function () {//增加成功后刷新
                    zzpUtils.refreshTable("#table");
                },
            });
        }
        //删除已有库位
        window.delRowDialog = function (id) {
            tabledata = $table.bootstrapTable('getData');
            var ids=[]
            ids.push(id);
            var data={"id": $('#kwzid').val(),"ids":ids}
            zzpUtils.confirm("您将删除选择的数据", function (index) {
                if(tabledata.length<2){
                    layer.msg("库位不可全部删除");
                }else{
                    zzpUtils.action({
                        url: "/wmslibrarypositiongroup/deletePosition",
                        data: JSON.stringify(data),
                        success: function (data) {
                            if(data.message!=""){
                                layer.msg(data.message);
                            }else{
                                layer.msg(data.title);
                            }
                            zzpUtils.refreshTable("#table");
                        }
                    })
                }
            })
        }
    });
</script>
</html>